import { TextAreaFormItem } from 'src/app/domain/form/form-item-textarea';
import { Injectable } from '@angular/core';

import { DropdownFormItem } from 'src/app/domain/form/form-item-dropdown';
// import { FormItemBase } from 'src/app/domain/form/form-Item-base';
import { TextboxFormItem } from 'src/app/domain/form/form-item-textbox';
import { of } from 'rxjs';
import { RadioFormItem } from 'src/app/domain/form/form-item-radio';
import { CalendarFormItem } from 'src/app/domain/form/form-item-calendar';
import { MultiSelectFormItem } from 'src/app/domain/form/form-item-multiSelect';
import { InputNumberFormItem } from 'src/app/domain/form/form-item-inputNumber';
import { FormItemBase } from 'src/app/domain/form/form-item-base';

@Injectable({
  providedIn: 'root',
})
export class FormItemService {
  // TODO: get from a remote source of formItem metadata
  getFormItems() {
    const FormItems: FormItemBase<string>[] = [
      new DropdownFormItem({
        key: 'brave',
        label: '勇敢等级',
        options: [
          { label: '全部', value: '' },
          { label: 'solid', value: 'Solid' },
          { label: 'great', value: 'Great' },
          { label: 'good', value: 'Good' },
          { label: 'unproven', value: 'Unproven' },
        ],
        // required: true,
        order: 3,
      }),

      new RadioFormItem({
        key: 'sex',
        label: '性别',
        options: [
          {
            label: '男',
            value: '1',
          },
          {
            label: '女',
            value: '0',
          },
        ],
        value: '1',
        required: true,
        order: 4,
      }),

      new TextAreaFormItem({
        key: 'remark',
        label: '备注',
        // value: 'Bombasto',
        // required: true,
        order: 5,
      }),

      new CalendarFormItem({
        key: 'startDate',
        label: '开始日期',
        // value: 'Bombasto',
        required: true,
        order: 6,
      }),
      new MultiSelectFormItem({
        key: 'hobby',
        label: '爱好',
        options: [
          { label: '唱歌', value: '1' },
          { label: '跳舞', value: '2' },
          { label: '运动', value: '3' },
          { label: '旅游', value: '4' },
        ],
        required: true,
        order: 7,
      }),
      new InputNumberFormItem({
        key: 'count',
        label: '数量',
        value: '123548',
        required: true,
        order: 8,
      }),

      new TextboxFormItem({
        key: 'name',
        label: '姓名',
        value: 'Bombasto',
        required: true,
        order: 1,
      }),

      new TextboxFormItem({
        key: 'email',
        label: '邮件地址',
        type: 'email',
        order: 2,
        required: true,
      }),
    ];

    return of(FormItems.sort((a, b) => a.order - b.order));
  }
}
